﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MESMian.EntityMapping
{
    public class DeviceMaintenancesMapping : IEntityTypeConfiguration<DeviceMaintenances>
    {
        public void Configure(EntityTypeBuilder<DeviceMaintenances> builder)
        {
            builder.ToTable("DeviceMaintenances");
            builder.HasKey(dm => dm.DeviceMaintenanceId);
            builder.Property(dm => dm.DeviceMaintenanceId)
                .HasComment("设备维修主键，自动编号");

            builder.Property(dm => dm.DeviceId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("维修设备，外键（Devices）");

            builder.Property(dm => dm.MaintainerId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("维修人员，外键（Users）");

            builder.Property(dm => dm.MaintenanceTime)
                .IsRequired()
                .HasColumnType("datetime")
                .HasComment("维修日期（填写日期）");

            builder.Property(dm => dm.Remark)
                .HasColumnType("varchar(150)")
                .HasComment("报修简述");

            builder.Property(dm => dm.Status)
                .IsRequired()
                .HasColumnType("int")
                .HasDefaultValue(0)
                .HasComment("数据状态（0正常，1删除），默认值0");

            builder.Property(dm => dm.CreateUserId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("创建人，外键（Users）");

            builder.Property(dm => dm.CreateTime)
                .IsRequired()
                .HasColumnType("datetime")
                .HasDefaultValueSql("GETDATE()")
                .HasComment("创建时间，默认值为当前时间");

            builder.Property(dm => dm.LastUpdateUserId)
                .HasColumnType("int")
                .HasComment("最后一次修改人，外键（Users）");

            builder.Property(dm => dm.LastUpdateTime)
                .HasColumnType("datetime")
                .HasComment("最后一次修改时间");
        }
    }


}

